Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Drawing to a Video Output

Your software draws images to a video output component in the same way that it draws to other video outputs: through a QuickDraw graphics world. You do this as follows:

  1. After selecting the video output component and display mode, as described in the previous sections, call the QTVideoOutputBegin function to give your software exclusive use of the video output device.
  2. If any other software is using the video output device, QTVideoOutBegin returns the error code videoOutputInUseErr . If this happens, your software can call the QTVideoOutGetCurrentClientName function to get the name of the software and then display an alert that says that the output device is not available and notes the software that is currently using it.

  3. Call QTVideoOutputGetGWorld to obtain the dimensions and resolution of the video output component's graphics world. This is the graphics world your software uses to draw images for the video.

  4. Allocate a graphics world for your software with 32 bits per pixel and the same dimensions and resolution as the video output component's graphics world.

  5. Draw the image to display into your software's graphics world.

  6. Create an image sequence for transferring the image to the video output.

  7. Call DecompressSequenceFrameS to send the image to the video output.
  8. This invokes the Image Compression Manager, which locates a image decompressor component that can convert the image into the pixel format required by the video output device.

    The image decompressor component then delivers the video data to the video output device, which displays the image on the video output hardware.

  9. Display another image or movie or call QTVideoOutputEnd to end the display and release control of the video output device.

Listing 2 illustrates how to create the image sequence and send it to the video output component.

Listing 2 Creating and sending an image sequence to a video output component

OSErr MakeImageSequenceForGWorld (GWorldPtr gw,
                                 GWorldPtr dest,
                                 long *imageSize,
                                 ImageSequence *seq)
{
    OSErr err = noErr;
    ImageDescriptionHandle desc = nil;
    ImageDescriptionPtr dp;
    PixMapHandle pixmap = gw->portPixMap;
    Rect bounds = (**pixmap).bounds;

    *seq = nil;
    *imageSize = ((**pixmap).rowBytes & 0x3fff) * dp->height;

    err = MakeImageDescriptionForPixMap (gw, &desc);
    if (err) goto bail;

    err = DecompressSequenceBeginS (seq, desc, dest, nil,
                                    &bounds, nil, ditherCopy,
                                    (RgnHandle)nil, 0,
                                    codecNormalQuality, anyCodec);
    if (err) goto bail;

bail:
    if (desc) DisposeHandle ((Handle)desc);
    return err;
}

{
    QTVideoOutputComponent videoOutput;
    GWorldPtr drawingBuffer = nil;
    GWorldPtr destGWorld;
    ImageSequence seq = nil;
    long imageSize;
    CodecFlags outFlags;

    QTVideoOutGetGWorld (videoOutput, &destGWorld);

    LockPixels (drawingBuffer->portPixMap);
    MakeImageSequenceForGWorld (drawingBuffer, destGWorld,
                                &imageSize, &seq);

    DecompressSequenceFrameS(seq,
                             GetPixBaseAddr (drawingBuffer->portPixMap),
                             imageSize, 0, &outFlags, nil);
}

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |